package com.it.refect;

/**
 * 目标：获取Class对象
 */
public class Test1Class {
    public static void main(String[] args) throws Exception {
        // 获取Class对象的三种方式：c1,c2,c3

        Class c1 = Student.class; // c1 代表整个学生类
        System.out.println(c1.getName());  // 全类名: com.it.refect.Student
        System.out.println(c1.getSimpleName()); // 简名：Student

        //得到class类的学生对象
        Class c2 = Class.forName("com.it.refect.Student");

        // 判断c1和c2的地址是否一样
        System.out.println(c1 == c2); // true ; c1和c2一样

        Student s = new Student();
        Class c3 = s.getClass();
        System.out.println(c3 == c2); // true
    }
}
